﻿@model IEnumerable<WebUI.Models.Hospital>  
@*一定注意，科室和病区概念在数据库和模型中是调换的---不要删除此注释*@ @*
@Html.Partial("NewLink", new NewLink("hospitals", "HospitalEdit"))*@
@{
    var ch = ViewBag.CurrentHosp as string;
    var cb = ViewBag.CurrentBingQu as string;
    var cd = ViewBag.CurrentDep as string;
    var cs = ViewBag.CurrentSubj as string;
}
<ul id="hospitaltree">
    <li>
        <div class="tree-r" id="r_0">
            <div class="catalog-title">
                常规随访管理:全部医院</div>
        </div>
        <ul>
            @foreach (var h in Model)
            {
                <li class='@(ch == h.HospitalID ? "" : "closed")'>
                    <div class="tree-h" id="h_@(h.HospitalID)"
                     title="[@Html.DisplayFor(m => h.HospCode) ] @Html.DisplayFor(m => h.HospStatusRef.OptionTitle)"
                     
                     >
                        @Html.DisplayFor(m => h.HospName)
                    </div>
                    @if (h.BingQus.Count > 0)
                    { 
                        <ul>
                            @foreach (var b in h.BingQus)
                            {
                                <li class='@(cb == b.ID ? "" : "closed")'>
                                    <div class="tree-b" id="b_@(b.ID)" title="">
                                        @Html.DisplayFor(m => b.Title)
                                    </div>
                                    @if (b.Departments.Count > 0)
                                    { 
                                        <ul>
                                            @foreach (var d in b.Departments)
                                            {
                                                <li class='@(cd == d.DepartmentID ? "" : "closed")'>
                                                    <div class="tree-d" id="d_@(d.DepartmentID)" title="">
                                                        @Html.DisplayFor(m => d.DepName)
                                                    </div>
                                                    @{
                                                var mss = d.QizSubjects.OrderByDescending(v => v.SortIdx).Where(v => v.SubjectType != "指标库").ToList();
                                                if (mss.Count > 0)
                                                { 
                                                        <ul>
                                                            @foreach (var s in mss)
                                                            {
                                                                <li class='closed'>
                                                                    <div class="tree-s" id="s_@(s.ID)" title="">
                                                                        @Ajax.ActionLink(s.Title, "SftMingXiList", new { ID = s.ID }, new AjaxOptions { LoadingElementId = "OnLoadingSpan", UpdateTargetId = "listview", OnFailure = "OnSiteError" })
                                                                    </div>
                                                                    @if (s.SubQizSubjects.Count > 0)
                                                                    {
                                                                        <ul>
                                                                            @foreach (var ss in s.SubQizSubjects)
                                                                            {                                                                
                                                                                <li>
                                                                                    <div class="tree-s" id="s_@(ss.ID)" title="">
                                                                                        @Ajax.ActionLink(ss.Title, "SftMingXiList", new { ID = ss.ID }, new AjaxOptions { LoadingElementId = "OnLoadingSpan", UpdateTargetId = "listview", OnFailure = "OnSiteError" })
                                                                                    </div>
                                                                                </li>
                                                                            }
                                                                        </ul>
                                                                    }
                                                                </li>
                                                            }
                                                        </ul>
                                                }
                                                    }
                                                </li>
                                            }
                                        </ul>
                                    }
                                </li>
                            }
                        </ul>
                    }
                </li>
            }
        </ul>
    </li>
</ul>
<div class="catalog-title">
    常规随访管理:特殊功能</div>
<div>
    @Ajax.ActionLink("SF-36生活质量调查表--模板", "SftMingXiList", new { ID = "10001" }, new AjaxOptions { LoadingElementId = "OnLoadingSpan", UpdateTargetId = "listview", OnFailure = "OnSiteError" })
</div>
<script type="text/javascript">
    $(function () {

        $("#hospitaltree").treeview();
        
        var urlbase="@Url.Action("HospAndDepartMgr")";
        var el=$("#EditLink").first();
        var dl=$("#DelLink").first();

        $('.tree-r').contextMenu('myMenuLv0', {
            bindings: {
                'NewLv1': function (t,m) {el.attr("href",urlbase+"?act=n&utid=treeview&sid="+t.id);el.click(); } 
            }
        });

        $('.tree-h').contextMenu('myMenuLv1', {
            bindings: {
                'NewLv2': function (t) { el.attr("href",urlbase+"?act=n&utid=treeview&sid="+t.id);el.click();  },
                'EditLv1': function (t) { el.attr("href",urlbase+"?act=e&utid=treeview&sid="+t.id);el.click(); },
                'DelLv1': function (t) { dl.attr("href",urlbase+"?act=d&utid=treeview&sid="+t.id);dl.click(); }
            }
        });

        $('.tree-b').contextMenu('myMenuLv2', {
            bindings: {
                'NewLv3': function (t) { el.attr("href",urlbase+"?act=n&utid=treeview&sid="+t.id);el.click(); },
                'EditLv2': function (t) { el.attr("href",urlbase+"?act=e&utid=treeview&sid="+t.id);el.click(); },
                'DelLv2': function (t) { dl.attr("href",urlbase+"?act=d&utid=treeview&sid="+t.id);dl.click(); }
            }
        });

        $('.tree-d').contextMenu('myMenuLv3', {
            bindings: {
                'NewLv4': function (t) { el.attr("href",urlbase+"?act=n&utid=treeview&sid="+t.id);el.click(); },
                'NewSF36': function (t) { el.attr("href",urlbase+"?act=x&utid=treeview&sid="+t.id);el.click(); },
                'EditLv3': function (t) { el.attr("href",urlbase+"?act=e&utid=treeview&sid="+t.id);el.click(); },
                'DelLv3': function (t) { dl.attr("href",urlbase+"?act=d&utid=treeview&sid="+t.id);dl.click(); }
            }
        });
        $('.tree-s').contextMenu('myMenuLv4', {
            bindings: {
                'EditLv4': function (t) {el.attr("href",urlbase+"?act=e&utid=treeview&sid="+t.id);el.click(); },
                'DelLv4': function (t) {  dl.attr("href",urlbase+"?act=d&utid=treeview&sid="+t.id);dl.click();  }
            }
        });
    });
</script>
